//
//  AppDelegate.swift
//  1010
//
//  Created by 米明 on 15/7/8.
//  Copyright (c) 2015年 米明. All rights reserved.
//

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
        DataCenter.setNowScore(score: 0)
        let df = UserDefaults.standard
        let isFirst =  df.bool(forKey: "firstOpen")
        if !isFirst {
            DataCenter.setSun(isSun: true)
            DataCenter.setMusicSwitch(isOn: true)
            df.set(true, forKey: "firstOpen")
        }
        
        showHome()
        
        // Override point for customization after application launch.
        return true
    }
   
    func getWindow() -> UIWindow? {
        if window == nil {
            window = UIWindow(frame: UIScreen.main.bounds)
            window?.makeKeyAndVisible()
        }
        return window
    }
    
    func showHome() {
        let homeV = HomeViewController()
        let naV = GameNavgationController(rootViewController: homeV)
        self.getWindow()?.rootViewController = naV
    }
}

